#include <iostream>
#include <stdlib.h>
#include <string.h>

using namespace std;

struct Stack{
    int data[5];
    int top;
};

Stack* init()
{
    Stack* s=(Stack*)malloc(sizeof(Stack));
    if(s==NULL) cout<<"error creat stack fail"<<endl;
    else
    {
        memset(s->data,0,sizeof(s->data));
        s->top=0;
        return s;
    }
}

void push_stack(Stack* s,int data)
{
   s->data[s->top]=data;
   s->top++;
}

void pop_stack(Stack* s)
{
    if(s->top!=0)
    {
        s->data[s->top]=0;
        s->top--;
    }
}

void display_stack(Stack* s)
{
    for(int n=s->top-1;n>=0;n--)
    {
        cout<<s->data[n]<<endl;
       
    }
}

int main ()
{
    Stack* s=init();
    int input[]={11,22,33,44,55};
    for(int i=0;i<5;i++)
    {
        push_stack(s,input[i]);
    }
    display_stack(s);
    pop_stack(s);
    display_stack(s);

    system("pause");
    return 0;
}

